﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using RahulBabar.SharePoint.Util.EmailUtility;

namespace RahulBabar.SharePoint.Util.TestEmailUtility.TestEmailConfiguration
{
    public partial class TestEmailConfigurationUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void FindEmailButton_Click(object sender, EventArgs e)
        {
            EmailConfigurationManager emailManager = new EmailConfigurationManager();
            EmailTemplate email = emailManager.GetEmailTemplate(EmailTemplateIdTextBox.Text.Trim());
            if (email != null)
            {
                EmailTemplateSubjectLabel.Text = email.EmailTemplateSubject;
                EmailTemplateBodyLabel.Text = email.EmailTemplateBody;
                MessageLabel.Text = "Email Retrieved Successfully.";
            }
            else
            {
                MessageLabel.Text = "Email Template not found.";
                EmailTemplateSubjectLabel.Text = "";
                EmailTemplateBodyLabel.Text = "";
            }
        }
    }
}
